package com.example.jiaju;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;

public class StartActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);
        initView();
    }

    private void initView(){
        SharedPreferences sp = getSharedPreferences("user",MODE_PRIVATE);
        SharedPreferences.Editor editor=sp.edit();
        Boolean isLogin=sp.getBoolean("isLogin",false) ;
        Boolean isFirst=sp.getBoolean("isFirst",true);

        //判断是否为第一次打开软件
        if(isFirst) {
            editor.putBoolean("isFirst", false).apply();

            startActivity(new Intent(StartActivity.this, IntroductoryActivity.class));
            finish();
        }else if(!isLogin){
            editor.putBoolean("isFirst", true).apply();
            startActivity(new Intent(StartActivity.this,LoginActivity.class));
            finish();
        }else {
            startActivity(new Intent(StartActivity.this,MainActivity.class));
            finish();
        }
    }
}